package com.hmkj.admin.controller.operate;

import com.hmkj.admin.controller.BaseController;
import com.hmkj.admin.utils.AdminSessionHelper;
import com.hmkj.common.baseMapper.GenericPo;
import com.hmkj.core.po.operate.Agent;
import com.hmkj.core.po.system.Admin;
import com.hmkj.core.service.operate.AgentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


/**
 * 公告管理
 */
@Controller
@RequestMapping(BaseController.BASE_URI)
public class AnnounceController extends BaseController {

    @Resource
    private AgentService agentService;

    @RequestMapping("/announce/list")
    public String list(ModelMap modelMap) {
        Admin admin = AdminSessionHelper.getCurrAdmin();
        List<Agent> agents ;
        if(admin.getType()==Admin.TYPE.T3.code){
            agents  = agentService.select(new Agent(agent -> {
                agent.setId(admin.getBussId());
                agent.setDelFlag(Agent.DELFLAG.NORMAL.code);
            }));
        }else{
             agents  = agentService.select(new Agent(agent -> {
                agent.setDelFlag(Agent.DELFLAG.NORMAL.code);
            }));
        }
        modelMap.put("agents", agents);
        modelMap.put("type",admin.getType());
        return ok("operate/announce/list");
    }

}
